<?php
function FontSizeSwitch($global_id) 
{
	global $pluginURL, $configVal, $blogid, $suri;
	requireComponent('Textcube.Function.misc');
	$data = misc::fetchConfigVal($configVal);
	$LargeSize = (!is_null($data) && array_key_exists('LargeSize', $data)) ? $data['LargeSize'] : "180%" ;
	$BiggerSize = (!is_null($data) && array_key_exists('BiggerSize', $data)) ? $data['BiggerSize'] : "130%" ;
	$OriginalSize = (!is_null($data) && array_key_exists('OriginalSize', $data)) ? $data['OriginalSize'] : "100%" ;
	$LargeLine = (!is_null($data) && array_key_exists('LargeLine', $data)) ? $data['LargeLine'] : 0.9 ;
	$BiggerLine = (!is_null($data) && array_key_exists('BiggerLine', $data)) ? $data['BiggerLine'] : 1.0 ;
	$OriginalLine = (!is_null($data) && array_key_exists('OriginalLine', $data)) ? $data['OriginalLine'] : 1.3 ;

	$entries = (substr($suri['directive'], 1, strlen($suri['directive'])))."_entries_" ;

	switch (getBlogSetting('language')) {
		case 'zh-TW':
			$text['Large'] = "超大字體";
			$text['Bigger'] = "放大字體";
			$text['Original'] = "原始字體";
		break;
		case 'zh-CN':
			$text['Large'] = "超大字体";
			$text['Bigger'] = "放大字体";
			$text['Original'] = "原始字体";		
		break;
		default:
			$text['Large'] = "Large Font";
			$text['Bigger'] = "Bigger Font";
			$text['Original'] = "Original Font";
	}
	$switcher = "<span title=\"".$text['Large']."(".$LargeSize.")\" style=\"cursor: pointer\" onmousedown=\"document.getElementById('".$entries.$global_id."').style.fontSize='".$LargeSize."';document.getElementById('".$entries.$global_id."').style.lineHeight=parseInt('".$LargeSize."')*".$LargeLine."+'%';\"><img src=\"".$pluginURL."/large.gif\" width=\"29\" height=\"21\" alt=\"".$text['Large']."(".$LargeSize.")\" /></span>" .
		"<span title=\"".$text['Bigger']."(".$BiggerSize.")\" style=\"cursor: pointer\" onmousedown=\"document.getElementById('".$entries.$global_id."').style.fontSize='".$BiggerSize."';document.getElementById('".$entries.$global_id."').style.lineHeight=parseInt('".$BiggerSize."')*".$BiggerLine."+'%';\"><img src=\"".$pluginURL."/bigger.gif\" width=\"29\" height=\"21\" alt=\"".$text['Bigger']."(".$BiggerSize.")\" /></span>" .
		"<span title=\"".$text['Original']."(".$OriginalSize.")\" style=\"cursor: pointer\" onmousedown=\"document.getElementById('".$entries.$global_id."').style.fontSize='".$OriginalSize."';document.getElementById('".$entries.$global_id."').style.lineHeight=parseInt('".$OriginalSize."')*".$OriginalLine."+'%';\"><img src=\"".$pluginURL."/original.gif\" width=\"29\" height=\"21\" alt=\"".$text['Original']."(".$OriginalSize.")\" /></span>";
	return $switcher;
}

function FontSizeSwitcher_post($target, $mother) 
{	
	global $suri;
	if($suri['directive']!="/rss" && $suri['directive']!="/m" && $suri['directive']!="/i/entry" && $suri['directive']!="/atom" && $suri['directive']!="/sync")
	{
		$switcher = FontSizeSwitch($mother);
		$entries = (substr($suri['directive'], 1, strlen($suri['directive'])))."_entries_" ;
		$target = "<div align=\"right\" style=\"height:21px;\">".$switcher."</div><div id=\"".$entries.$mother."\">" . $target ."</div>";
	}
	return $target;
}

function FontSizeSwitcher_comment($target, $mother) 
{	
	global $suri;
	if($suri['directive']!="/rss" && $suri['directive']!="/m" && $suri['directive']!="/i/comment")
	{
		$switcher = FontSizeSwitch($mother['id']);
		$entries = (substr($suri['directive'], 1, strlen($suri['directive'])))."_entries_" ;
		$target = "<div align=\"right\" style=\"height:21px;\">".$switcher."</div><div id=\"".$entries.$mother['id']."\">" . $target ."</div>";
	}
	return $target;
}

function FontSizeSwitcher_DataSet($data)
{
	requireComponent('Textcube.Function.misc');
	$data = misc::fetchConfigVal($configVal);
	if(is_null($data)){
		$data['LargeSize']		= "180%";
		$data['BiggerSize']		= "130%";
		$data['OriginalSize']	= "100%";
		$data['LargeLine']		= 0.9 ;
		$data['BiggerLine']	= 1.0 ;
		$data['OriginalLine']	= 1.3 ;
	}
	$cfg = misc::fetchConfigVal($data);
	return true;
}

?>
